﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DLTN.Entities;
using DLTN.Data;
using System.Data;
public partial class VideoND : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Pager1.CurrentIndex = 1;
            hienvideo();
            binding(Pager1.CurrentIndex = 1);
        }
    }
    protected void Pager1_Command(object sender, CommandEventArgs e)
    {
        int currnetPageIndex = Convert.ToInt32(e.CommandArgument);
        Pager1.CurrentIndex = currnetPageIndex;
        binding(currnetPageIndex - 1);
    }
    protected void hienvideo()
    {
        string strHTML = "";
        int TotalRows = 0;
        string WhereClause = "1=1 and id=" + Convert.ToInt32( Request.Params["id"]) + "";
        TList<Video> TList_Video = DataRepository.VideoProvider.GetPaged(WhereClause, "Id DESC", 0, 1, out TotalRows);
        if (TList_Video.Count > 0)
        {
            ltrTitle.Text = TList_Video[0].TieuDe;

            String c = "//www.youtube.com/embed/";
           
            strHTML += "<iframe width=\"100%\" height=\"390px\" src=\"" + c + TList_Video[0].MaCode + "\" frameborder=\"0\" allowfullscreen></iframe>";                
            
            disPlayVideoRequest.Text = strHTML;
            hienthidiengiai.Text = TList_Video[0].DienGiai;
        }       
    }
    private void binding(int PageNo)
    {
        int TotalRows = 0;
        string WhereClause = "1=1";
        TList<Video> TList_Video = DataRepository.VideoProvider.GetPaged(WhereClause, "id DESC", PageNo - 1, Pager1.PageSize, out TotalRows);
        
        dlVideo.DataSource = TList_Video;
        dlVideo.DataBind();

        Pager1.ItemCount = TotalRows;
        if (TotalRows <= Pager1.PageSize)
            Pager1.Visible = false;
        else
            Pager1.Visible = true;
    }
    public string GetTieuDe(object Char)
    {
        string s = Char.ToString();
        return Common.ConvertToUnSign(s);
    }
}